﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Configuration;

namespace QuanLyVatLieuXayDung
{
    public partial class Lập_Hóa_Đơn : Form
    {
        private bool mousePressed = false;
        private Point diff = new Point(0, 0);
        public Lập_Hóa_Đơn()
        {
            BitmapRegion.BitmapRegion.CreateControlRegion(this, Properties.Resources.LapHoaDon);
            InitializeComponent();
            this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
            this.UpdateStyles();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void Lập_Hóa_Đơn_Load(object sender, EventArgs e)
        {   
        }

        private void Lập_Hóa_Đơn_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                mousePressed = true;

                Point p = new Point(e.X, e.Y);
                p = PointToScreen(p);
                diff.X = p.X - DesktopLocation.X;
                diff.Y = p.Y - DesktopLocation.Y;
            }
        }

        private void Lập_Hóa_Đơn_MouseMove(object sender, MouseEventArgs e)
        {
            if (mousePressed && (e.Button & MouseButtons.Left) != 0)
            {
                Point p = new Point(e.X, e.Y);
                p = PointToScreen(p);
                p.X -= diff.X;
                p.Y -= diff.Y;
                DesktopLocation = p;
            } 
        }

        private void Lập_Hóa_Đơn_MouseUp(object sender, MouseEventArgs e)
        {
            mousePressed = false;
        }
    }
}
